package cn.yup.service.impl;

import cn.yup.domain.Sample;
import cn.yup.mapper.SampleMapper;
import cn.yup.query.SampleQueryObject;
import cn.yup.service.ISampleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service   // 表示把该类创建对象交给Spring 管理  @controller
public class SampleServiceImpl implements ISampleService {


    @Autowired //  表示 从spring 容器中 获取 SampleMapper 对象 赋给 sampleMapper 这个变量
    private SampleMapper sampleMapper;


    @Override
    public PageInfo findAll(SampleQueryObject queryObject) {
        // PageHelper 插件处理分页
        PageHelper.startPage(queryObject.getCurrentPage(),queryObject.getPageSize());
        // 当前页的数据
       List<Sample> samples =  sampleMapper.findAll(queryObject);

        return  new  PageInfo(samples);
    }

    @Override
    public void insertSamples(List<Sample> samples) {
        sampleMapper.insertSamples(samples);
    }


}
